package com.qinglei.recoup.system.service.impl;

import com.qinglei.recoup.common.exception.RedisConnectException;
import com.qinglei.recoup.common.service.RedisService;
import com.qinglei.recoup.common.utils.JsonUtils;
import com.qinglei.recoup.system.domain.VitalSignsAlarm;
import com.qinglei.recoup.system.dao.VitalSignsAlarmMapper;
import com.qinglei.recoup.system.service.VitalSignsAlarmService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author dqh
 */
@Service
public class VitalSignsAlarmServiceImpl extends ServiceImpl<VitalSignsAlarmMapper, VitalSignsAlarm> implements VitalSignsAlarmService {

    @Resource
    private RedisService redisService;

    @Override
    public VitalSignsAlarm getVitalSignsAlarm(String key) throws RedisConnectException {
        String s = redisService.get(key);
        if(StringUtils.isEmpty(s))
            return null;
        VitalSignsAlarm vitalSignsAlarm = JsonUtils.jsonToBean(s, VitalSignsAlarm.class);
        return vitalSignsAlarm;
    }
}
